<?php
namespace app\admin\controller;
use com\Auth;
use think\Session;
use think\Db;
class Admin extends \think\Controller 
{
    protected $auth_rule;
    protected $auths;
    protected function _initialize() {
        $admin = Session::get('admin');
        if(!$admin){
            $this->error('非法访问进入登录页面','manager/index/index');
        }
        //进行权限判断
        $auth =new Auth();
        $rq=  $this->request; 
        if(!$auth->check($rq->module().'/'.$rq->controller().'/'.$rq->action(),$admin['id'])){
            $this->error('没有权限','manager/index/index');
        }else {
            $auths = $auth->getGroups($admin['id']);
            $this->auths = $auths;
            $this->auth_rule = Db::name('auth_rule')->where('id','in',($auths[0]['rules']))->select();
            //$this->setNav('abc');
            
        }
    }
	protected function setNav($navStr) {
		//网站导航
	    $rq=  $this->request;	    
		$nav = '<a >首页</a><a href="/'.$rq->module().'/'.$rq->controller().'/'.$rq->action().'">'.$navStr.'</a>';
		$this->assign('nav',$nav);
	}
}
